package cn.tedu.imop.basic.dao.repository.impl;

import cn.tedu.imop.basic.dao.mapper.MemberGroupMapper;
import cn.tedu.imop.basic.dao.repository.MemberGroupRepository;
import cn.tedu.imop.basic.entity.MemberGroup;
import cn.tedu.imop.common.context.PageContext;
import cn.tedu.imop.common.pojo.PageData;
import cn.tedu.imop.common.utils.PageInfoToPageDataConverter;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MemberGroupRepositoryImpl implements MemberGroupRepository {
    private MemberGroupMapper memberGroupMapper;
    public MemberGroupRepositoryImpl(MemberGroupMapper memberGroupMapper) {
        this.memberGroupMapper = memberGroupMapper;
    }
    @Override
    public int insertMemberGroup(MemberGroup memberGroup) {
        int rows=memberGroupMapper.insert(memberGroup);
        return rows;
    }

    @Override
    public PageData<MemberGroup> selectMemberGroupList(MemberGroup memberGroup) {
        PageContext.startPage();
        List<MemberGroup> list=memberGroupMapper.selectList(memberGroup);
        return PageInfoToPageDataConverter.convert(new PageInfo<>(list));
    }
}
